#!/usr/bin/python
#coding:utf8

"""
    Builder
"""

# # Director
# class Director(object):
#     def __init__(self):
#         self.builder = None

#     def construct_building(self):
#         self.builder.new_building()
#         self.builder.build_floor()
#         self.builder.build_size()

#     def get_building(self):
#         return self.builder.building


# # Abstract Builder
# class Builder(object):
#     def __init__(self):
#         self.building = None

#     def new_building(self):
#         self.building = Building()


# # Concrete Builder
# class BuilderHouse(Builder):
#     def build_floor(self):
#         self.building.floor = 'One'

#     def build_size(self):
#         self.building.size = 'Big'


# class BuilderFlat(Builder):
#     def build_floor(self):
#         self.building.floor = 'More than One'

#     def build_size(self):
#         self.building.size = 'Small'


# # Product
# class Building(object):
#     def __init__(self):
#         self.floor = None
#         self.size = None

#     def __repr__(self):
#         return 'Floor: %s | Size: %s' % (self.floor, self.size)


# # Client
# if __name__ == "__main__":
#     director = Director()
#     director.builder = BuilderHouse()
#     director.construct_building()
#     building = director.get_building()
#     print(building)
#     director.builder = BuilderFlat()
#     director.construct_building()
#     building = director.get_building()
#     print(building)

###############################################################
class food:
    def getPrice(self):
        return self.price

    def getName(self):
        return self.name

class Burger(food):
    def __init__(self):
        self.name = "cheese burger"
        self.price = 10.0

class Chip(food):
    def __init__(self):
        self.name = "chips"
        self.price = 5.0

class Coke(food):
    def __init__(self):
        self.name = "coke"
        self.price = 3.0

# Builder
class OrderBuilder:
    def __init__(self):
        self.burger = None
        self.snack = None
        self.beverage = None

    def addBurger(self, burger):
        if not burger: return
        self.burger = burger()
    
    def addSnack(self, snack):
        if not snack: return
        self.snack = snack()

    def addBeverage(self, beverage):
        if not beverage: return
        self.beverage = beverage()
    
    def build(self):
        return Order(self)

# Director - constructs objects using the builder interface
class Order:
    def __init__(self, order_builder):
        self.builder = order_builder

    def cater(self):
        order_list = []
        order_list.append(self.builder.burger)
        order_list.append(self.builder.snack)
        order_list.append(self.builder.beverage)
        return [x.name for x in order_list if x is not None]


class OrderTable:
    def __init__(self,order_builder):
        self.builder = order_builder
    
    def createOrder(self,burger,snack,beverage):
        self.builder.addBurger(burger)
        self.builder.addSnack(snack)
        self.builder.addBeverage(beverage)
        order = self.builder.build()
        print(order.cater())

if __name__ == "__main__":
    order_builder = OrderBuilder()
    table1 = OrderTable(order_builder)
    table1.createOrder(Burger, None, Coke)

